#ifndef PAIR
#define PAIR

#include <iostream>
#include <utility>

namespace wk
{
    template <typename T1, typename T2>
    struct pair
    {

        pair() : first(), second() {}

        pair(const T1 &t1, const T2 &t2) : first(t1), second(t2) {}

        template <typename F, typename S>
        pair(const pair<F, S> &other) : first(other.first), second(other.second) {}

        // 移动语义的诉求是转移资源，避免深拷贝，为了提高性能，这里如果给了模板参数，
        // 传进来的参数类型和现在不一样，一来要走隐式类型转换，二来还可能进行深拷贝，不符合移动语义的诉求
        pair(const pair &&other) : first(std::move(other.first)), second(std::move(other.second)) {}

        // 移动赋值运算符
        pair &operator=(const pair &&other)
        {
            first = std::move(other.first);
            second = std::move(other.second);
            return *this;
        }

        void swap(pair &other)
        {
            swap(first, other.first);
            swap(second, other.second);
        }

    public:
        T1 first;
        T2 second;
    };

    template <typename T1, typename T2>
    const pair<T1, T2> make_pair(const T1 first, const T2 second)
    {
        return pair<T1, T2>(first, second);
    }
}

#endif
